import axios from './axios';

// 用户登录接口
export function loginapi(data: {
    userName : string,
    userPwd: string,
}) {
    return axios({
        url: `/user/shoppingLogin.php?userName=${data.userName}&userPwd=${data.userPwd}`,
        method: 'get',
        data
    })
}
// 首页数据接口
export function homedata(data: {}) {
    return axios({
        url:  '/home/getHomeData.php',
        method: 'post',
        data
    })
}
// 商品的类别
export function leibiedata(data: {product_type:any}) {
    return axios({
        url:  `/product/getProductTypes.php?product_type=${data.product_type}`,
        method: 'get',
        data
    })
}
// 商品的详情
export function xqapi(data: {product_id:any}) {
    return axios({
        url:  `/product/getProductDetail.php?product_id=${data.product_id}`,
        method: 'get',
        data
    })
}
// 订单的评论
export function pinglun(data: {pro_id:any}) {
    return axios({
        url:  `product/getProductEva.php?pro_id=${data.pro_id}`,
        method: 'post',
        data
    })
}
// 查看购物车
export function lookcart(data: {shop_userCode:any}) {
    return axios({
        url:  `/product/getShoppingCart.php?shop_userCode=${data.shop_userCode}`,
        method: 'post',
        data
    })
}
// 我的页api
export function userapi(data: {user_code:any}) {
    return axios({
        url: `/user/getUserData.php?shop_userCode=${data.user_code}`,
        method: 'get',
        params:data
    })}
    // 获取收货地址
export function ressList(data: {userCode:any}) {
    return axios({
        url: `/user/getAddressList.php?userCode=${data.userCode}`,
        method: 'get',
        params:data
    })}
// 订单页
export function dingdan(data: {shop_userCode:any,user_shopType:any}) {
    return axios({
        url: `/product/getOrderList.php?shop_userCode=${data.shop_userCode}&user_shopType=${data.user_shopType}`,
        method: 'get',
        params:data
    })
}
// 删除地址
export function deldizhi(data: {ress_userCode:any,ress_code:any}) {
    return axios({
        url: `/user/delAddress.php?ress_userCode=${data.ress_userCode}&ress_code=${data.ress_code}`,
        method: 'post',
        data
    })
}
// add添加地址
export function adddizhi(data:{
ress_userCode:any,
ress_name:any,//收货人姓名
ress_mobile:any,//收货人手机号
ress_ressCode:any,
ress_detail:any,//收货地址详情
ress_type:any,//1 家 2 公司 3 学校
ress_default:any,//1 非默认 2 默认
ress_code:any,//收货省市区地址
ress_text:any}) {
    return axios({
        url: `/user/addAddress.php?ress_userCode=${data.ress_userCode}&ress_name=${data.ress_name}&ress_mobile=${data.ress_mobile}
        &ress_ressCode=${data.ress_ressCode}&ress_detail=${data.ress_detail}&ress_type=${data.ress_type}&ress_default=${data.ress_default}&ress_code=${data.ress_code}&ress_text=${data.ress_text}`,
        method: 'post',
        data
    })
}
// 加入购物车
export function addShoppingCart(data: {   
      shop_userCode:any,
        shop_proTitle: any,
       shop_proPrice: any,
     shop_proImg: any,
       shop_proCount: any,
      shop_proId: any,}     
) {
    return axios({
        url:  `product/addShoppingCart.php?shop_userCode=${data.shop_userCode}&shop_proTitle=${data.shop_proTitle}&shop_proPrice=${data.shop_proPrice}
        &shop_proImg=${data.shop_proImg}&shop_proCount=${data.shop_proCount}&shop_proId=${data.shop_proId}`,
        method: 'post',
        data
    })
}